<?php
class autoWidget extends CWidget
{
	public $type=0;
	public $class="autokey";
	public $gid ;
	
    public function init()
	{
		$this->registerClientScript();
	}
	
	public function run()
	{
?>
 	<script>
	$(function() {
		$( ".<?php echo $this->class;?>" ).autocomplete({
			source: "/admin/admin/ajaxKeyword/getkeyword?type=<?php echo $this->type;?>",
			minLength: 1,
			select: function( event, ui ) {
				$(".<?php echo $this->class;?>").val(ui.item.label);
				<?php if($this->type=="zttitle"){?>
					$( "#imageSearch" ).val( ui.item.label );
				    $( "#cls" ).val( ui.item.value );
	                $("#way2").attr("checked","true");
	  				return false;
				<?php }?>
				<?php if($this->type=="zbsearch" or $this->type=="odaysearch" or $this->type=="downsearch"){?>
					$( "#<?php echo $this->gid;?>_searchgame" ).val( ui.item.label );
					$( "#<?php echo $this->gid;?>_gameid" ).val( ui.item.value ); 
			  			return false;
				<?php }?>
				<?php if($this->type=="odayxl"){?>
					$("#hid").val(ui.item.values);
				<?php }?>
			}
		});
	});
	</script>
<?php 
	}
	
	protected function registerClientScript()
	{
		$cs=Yii::app()->clientScript;
	    $cs->registercssFile(Yii::app()->request->baseUrl."/public/css/jquery-ui.css");
	    $cs->registerScriptFile(Yii::app()->request->baseUrl."/public/js/jquery-ui.js");
	    $cs->registercssFile(Yii::app()->request->baseUrl."/public/css/style.css");
	}
}
?>